package com.telit.firecommand.controller;

import com.telit.common.entity.DataReturn;
import com.telit.firecommand.service.IGeoXzqhCunService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 村 前端控制器
 * </p>
 *
 * @author yummy
 * @since 2021-10-20
 */
@RestController
@RequestMapping("/geo-xzqh-cun")
@Api(tags = "村数据资源", description = "/geo-xzqh-cun")
public class GeoXzqhCunController {

    @Autowired
    private IGeoXzqhCunService geoXzqhCunService;

    /**
     * 根据经纬度查询行政区划
     *
     * @param longitude 经度
     * @param latitude  纬度
     *
     * @return 行政区划
     */
    @GetMapping("/getDistrictByPoint")
    @ApiOperation("根据点查看村级行政区划")
    public DataReturn getDistrictByPoint(@RequestParam(value = "longitude") String longitude,
                                         @RequestParam(value = "latitude") String latitude) {
        return DataReturn.ok(geoXzqhCunService.getDistrictByPoint(longitude, latitude));
    }



    @GetMapping(value = "/getNameFromCode",produces = "application/json;charset=UTF-8")
    @ApiOperation("根据行政区划code查询名称")
    public DataReturn getNameFromCode(@RequestParam("code") String code){
        return DataReturn.ok(geoXzqhCunService.getNameFromCode(code));
    }

}
